﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using LinkCard.CustomerView.Common;
using LinkCard.Dao;
using LinkCard.Model;

namespace LinkCard.CustomerView.Controls
{
    public partial class Footer : System.Web.UI.UserControl
    {
        public AppEnv _Instance = AppEnv.Instance();

        #region Variable declaration

        private int PageSize = 42;
        private int CurrentPage = 1;
        private int TotalPageCount = 1;
        
        #endregion

        protected void Page_Load(object sender, EventArgs e)
        {
            //LoadSuppliers();
        }
        //private List<SupplierObject> LoadSuppliers()
        //{
        //    try
        //    {
        //        Dao.SupplierDao _suppliesDao = new Dao.SupplierDao();
        //        Dao.DealDao _dealDao = new Dao.DealDao();
                
        //        //List<LinkCard.Model.Supplier> _listSupplies = _suppliesDao.GetListPaged(CurrentPage, PageSize, ref TotalPageCount);
        //        List<LinkCard.Model.Supplier> _listSupplies = _suppliesDao.GetListPaged();

        //        List<SupplierObject> lst = new List<SupplierObject>();
        //        foreach (var _supplier in _listSupplies)
        //        {
        //            SupplierObject sTemp = new SupplierObject();

        //            sTemp.ID = _supplier.SupplierID;
        //            sTemp.Logo = HttpUtility.HtmlDecode(_supplier.Logo);
        //            sTemp.Name = HttpUtility.HtmlDecode(_supplier.Name);
        //            sTemp.LogoHome = HttpUtility.HtmlDecode(_supplier.LogoHome);

        //            List<Model.Deal> lastestDeal = new List<Model.Deal>();
        //            var listDeal = _dealDao.GetAllBySupplier(_supplier.SupplierID);
        //            if (listDeal != null && listDeal.Count > 0)
        //                lastestDeal = _dealDao.GetLatestDealBySupplier(_supplier.SupplierID, 1);

        //            //#region Popup Lastest Deal

        //            //if (lastestDeal.Count > 0)
        //            //{
        //            //    sTemp.LastDeal_Description = HttpUtility.HtmlDecode(lastestDeal[0].Description);
        //            //    sTemp.LastDeal_Detail = HttpUtility.HtmlDecode(lastestDeal[0].Detail);
        //            //    sTemp.LastDeal_Name = HttpUtility.HtmlDecode(lastestDeal[0].Name);
        //            //    sTemp.LastDeal_ID = lastestDeal[0].DealID;

        //            //    var album = Utils.Utilities.GetProductImage(lastestDeal[0].Image);

        //            //    if (album != null && album.Count > 0)
        //            //    {
        //            //        if (album.Count >= 1)
        //            //            sTemp.LastDeal_Img1 = HttpUtility.HtmlDecode(album[0]);
        //            //        if (album.Count >= 2)
        //            //            sTemp.LastDeal_Img2 = HttpUtility.HtmlDecode(album[1]);
        //            //        if (album.Count >= 3)
        //            //            sTemp.LastDeal_Img3 = HttpUtility.HtmlDecode(album[2]);
        //            //    }
        //            //}

        //            //#endregion

        //            lst.Add(sTemp);
        //        }

        //        rptSupplier.DataSource = lst;
        //        rptSupplier.DataBind();
        //        // Show PagerControl
        //        //ltrPaging.Text = CustomerView.Common.Pager.Create(CurrentPage, TotalPageCount);

        //        return lst;

        //    }
        //    catch (Exception ex)
        //    {
        //        throw new Exception(ex.Message);
        //    }

        //}

        //public class SupplierObject
        //{
        //    public long ID { get; set; }
        //    public string Logo { get; set; }
        //    public string LogoHome { get; set; }
        //    public string Name { get; set; }

        //    public string LastDeal_Name { get; set; }
        //    public long LastDeal_ID { get; set; }
        //    public string LastDeal_Description { get; set; }
        //    public string LastDeal_Detail { get; set; }
        //    public string LastDeal_Img1 { get; set; }
        //    public string LastDeal_Img2 { get; set; }
        //    public string LastDeal_Img3 { get; set; }

        //    public SupplierObject()
        //    {
        //        ID = 0;
        //        Logo = "";
        //        Name = "";
        //        LogoHome = "";

        //        LastDeal_Name = "";
        //        LastDeal_ID = 0;
        //        LastDeal_Description = "";
        //        LastDeal_Detail = "";
        //        LastDeal_Img1 = "";
        //        LastDeal_Img2 = "";
        //        LastDeal_Img3 = "";
        //    }
        //}
    }
}